<template>
  <input type="text" v-model="cityName">
</template>

<script setup>
    import {ref , watch} from 'vue';
    const cityName = ref('baoding');
    watch(cityName,(newValue, oldValue) => {
        if(newValue === 'baoding'){
            alert('你输入的是保定')
        }
        console.log('新值是'+newValue)
        console.log('旧值是'+oldValue)
    }, {
        immediate: true
    })
</script>

<style>

</style>